import React, { Component } from 'react'
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link
} from "react-router-dom";
import routes from './routers/index'
export default class App extends Component {
  render() {
    return (
      <div>
        <Router>
          <Link to="/">home</Link>
          <Link to='/about'>about</Link>
          <Link to='/detail'>detail</Link>
          <Switch>
            {routes.map(item => {
              if (item.path === '/') {
                return (<Route key={item.path} exact path={item.path} component={item.component}></Route>)
              } else {
                return (<Route key={item.path} path={item.path} component={item.component}></Route>)
              }
            })
            }
          </Switch>
        </Router>
      </div>
    )
  }
}

